/*
 * 组件注释
 * @Author: machinist_wq
 * @Date: 2022-05-03 15:52:38
 * @LastEditors: machinist_wq
 * @LastEditTime: 2022-06-30 15:56:09
 * @Description:
 * 人生无常！大肠包小肠......
 */
"use strict";
import hljs from "highlight.js/lib/core";
import xml from "highlight.js/lib/languages/xml";
import json from "highlight.js/lib/languages/json";
import javascript from "highlight.js/lib/languages/javascript";
import "highlight.js/styles/atom-one-dark-reasonable.css";

/*
 * 组件注释
 * create by wuqiong
 * creation time 2022/04/19
 * highlight
 * */

hljs.registerLanguage("xml", xml);
hljs.registerLanguage("json", json);
hljs.registerLanguage("javascript", javascript);

const Index = ({ language, code }: { language: string; code: string }) => {
  const highlightedCode = hljs.highlight(code, { language: language }).value;

  return (
    <pre>
      <code
        className={`hljs ${language}`}
        dangerouslySetInnerHTML={{ __html: highlightedCode }}
      />
    </pre>
  );
};
export default Index;
